#!/usr/bin/python

###############################
## A base function for plots ##
###############################

#######################################################      
## Set PyRoot Environment and PlotConfig Path first ###
#######################################################
import sys
ROOTSYS = '/afs/atlas.umich.edu/opt/root/lib'
sys.path.append(ROOTSYS)
PlotConfig='../'
PlotConfig2='.'
sys.path.append(PlotConfig)
sys.path.append(PlotConfig2)

#####################
## Import Module  ###
#####################
import array
import os
import glob
from math import sqrt,fabs,sin
from ROOT import TFile,TTree,TChain,TBranch,TH1,TH1F,TList
from ROOT import TLorentzVector
from ROOT import THStack,TCanvas,TLegend,TColor,TPaveText
from ROOT import gStyle,gDirectory

####################
## Import Template #
####################
from plot_template import plot_template
from plot_template_combined import plot_template_combined

###############
## Plotting ###
###############
RatioSize=0.2
RatioErr=-1
RatioMin,RatioMax=0,3
RatioAdj=0

ShowMCErr=1
MCErreeee=0.062
MCErreemm=0.044
MCErrmmee=0.044
MCErrmmmm=0.039
MCErr4l=0.044

plot_config='plot_configure'

histoDir='NOM'

#ATLAS='ATLAS For Approval'
ATLAS='ALTAS Preliminary'
figFormat='all'
ch_xleg=0.57

yscale=2

####### SF, PtZ1
Xmin, Xmax=0, 260
Rebin=20
Events=str('Events / %dGeV' % Rebin)
hname=histoDir+'_incl_SF_PtZ1'
hxt='Leading lepton pair p_{T} [GeV]'
MCErr=MCErr4l
plot_template(histodir=histoDir,hname=hname,configfile=plot_config,hxt=hxt,hyt=Events,hrebin=Rebin,xmin=Xmin,xmax=Xmax,yscale=yscale,ratio=RatioSize,ratio_min=RatioMin,ratio_max=RatioMax,ratio_adj=RatioAdj,ratio_err=RatioErr,show_mcerr=ShowMCErr,percent_mcerr=MCErr,showATLAS=ATLAS,figformat=figFormat,ch_xleg=ch_xleg)

####### SF, PtZ2
Xmin, Xmax=0, 260
Rebin=20
Events=str('Events / %dGeV' % Rebin)
hname=histoDir+'_incl_SF_PtZ2'
hxt='Subleading lepton pair p_{T} [GeV]'
MCErr=MCErr4l
plot_template(histodir=histoDir,hname=hname,configfile=plot_config,hxt=hxt,hyt=Events,hrebin=Rebin,xmin=Xmin,xmax=Xmax,yscale=yscale,ratio=RatioSize,ratio_min=RatioMin,ratio_max=RatioMax,ratio_adj=RatioAdj,ratio_err=RatioErr,show_mcerr=ShowMCErr,percent_mcerr=MCErr,showATLAS=ATLAS,figformat=figFormat,ch_xleg=ch_xleg)

####### SF, PtZZ
Xmin, Xmax=0, 260
Rebin=20
Events=str('Events / %dGeV' % Rebin)
hname=histoDir+'_incl_SF_PtZZ'
hxt='Four-lepton p_{T} [GeV]'
MCErr=MCErr4l
plot_template(histodir=histoDir,hname=hname,configfile=plot_config,hxt=hxt,hyt=Events,hrebin=Rebin,xmin=Xmin,xmax=Xmax,yscale=yscale,ratio=RatioSize,ratio_min=RatioMin,ratio_max=RatioMax,ratio_adj=RatioAdj,ratio_err=RatioErr,show_mcerr=ShowMCErr,percent_mcerr=MCErr,showATLAS=ATLAS,figformat=figFormat,ch_xleg=ch_xleg)

